#include <Servo.h>
Servo d[4];
int j[4]={90,90,180,45};
int v=15;

void set()
{
  for(int i=0;i<4;i++)
  {
    d[i].write(j[i]);
  }
}

void setup() {
  // put your setup code here, to run once:
  d[0].attach(6);
  delay(200);
  d[1].attach(9);
  delay(200);
  d[2].attach(10);
  delay(200);
  d[3].attach(11);
  delay(200);
  set();
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  int a=9;
  if(Serial.available())
    a=Serial.parseInt();
  switch(a)
  {
    case 0:
      j[0]+=v;
      Serial.println("j[0]="+j[0]);
      break;
    case 1:
      j[0]-=v;
      Serial.println("j[0]="+j[0]);
      break;
    case 2:
      j[1]+=v;
      Serial.println("j[1]="+j[1]);
      break;
    case 3:
      j[1]-=v;
      Serial.println("j[1]="+j[1]);
      break;
    case 4:
      j[2]+=v;
      Serial.println("j[2]="+j[2]);
      break;
    case 5:
      j[2]-=v;
      Serial.println("j[2]="+j[2]);
      break;
    case 6:
      j[3]+=v;
      Serial.println("j[3]="+j[3]);
      break;
    case 7:      
      j[3]-=v;
      Serial.println("j[3]="+j[3]);
      break;
  }
  set();

  
  /*for(int i=0;i<180;i+=v)
  {
    d[2].write(i);
  }
  for(int i=180;i>0;i-=v)
  {
    d[2].write(i);
  }//*/
   
}
